module hand_merge #(
	parameter CHANNEL = 2
)(
	input  [CHANNEL -1:0]in_valid,
	output [CHANNEL -1:0]in_ready,
	
	output				 out_valid,
	input				 out_ready
);

genvar i;
genvar j;
generate
for(i=0; i<CHANNEL; i=i+1)begin
    wire [CHANNEL -1:0] mask = {{(CHANNEL-1){1'b0}},1'b1} << i;
    wire [CHANNEL -1:0] in_valid_mask = in_valid | mask;
    assign in_ready[i] = out_ready && (&in_valid_mask);
end
endgenerate

assign out_valid = &in_valid;

endmodule
